﻿@model IEnumerable<CinemaCommon.Entities.Room>

@{
    ViewBag.Title = "Rooms";
}
<header>
    @section scripts
    {
        <script type="text/javascript" src="~/Scripts/Room_Index.js"></script>
    }
</header>

<h2>Rooms</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Cinema.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Movie.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.MaxSeats)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ReservedSeats)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.HasFreeSeats)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Income)
            </th>
            <th></th>
            <th>
                Add / Remove Persons
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.ActionLink(item.Cinema.Name, "Details", new {controller = "Cinema", id = item.CinemaId})
@*                    @Html.DisplayFor(modelItem => item.Cinema.Name)*@
                </td>
                <td>
                    @Html.ActionLink(item.Name, "Details", new { id = item.RoomId})
@*                    @Html.DisplayFor(modelItem => item.Name)*@
                </td>
                <td>
                    @Html.ActionLink(item.Movie.Name, "Details", new {controller = "Movie", id = item.MovieId})
@*                    @Html.DisplayFor(modelItem => item.Movie.Name)*@
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MaxSeats)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ReservedSeats)
                </td>
                <td>
                    @if (@item.HasFreeSeats)
                    {
                        <span class="label label-success">Seats available</span>
                    }
                    else
                    {
                        <span class="label label-important">All seats taken</span>
                    }
                </td>
                <td>
                    @item.Income.ToString("0.#0 €")
                </td>
                <td>
@*                    @Html.ActionLink("Edit", "Edit", new { id = item.RoomId }) |*@
@*                    @Html.ActionLink("Details", "Details", new { id = item.RoomId }) |*@
@*                    @Html.ActionLink("Delete", "Delete", new { id = item.RoomId })*@
                </td>
                <td>
                    <div class="editor-field">
                        @Html.HiddenFor(modelItem => item.RoomId)
                        <input class="addRemoveInput" type="text" value="1" />
                        @*<input class="addRemoveBtn btn btn-primary" type="button" value="Add/Remove" />*@
                        <input class="addBtn btn btn-primary" type="button" value="Add/Remove" />
                        <input class="removeBtn btn btn-primary" type="button" value="Add/Remove" />
                    </div>
                </td>
            </tr>
        }
    </tbody>

</table>
